package com.saer.client.tab.admin.permissions;

import com.saer.client.form.admin.permission.PermissionsSearchForm;
import com.saer.client.grid.admin.permissions.PermissionsGrid;
import com.saer.client.grid.admin.permissions.UserDetailsGrid;
import com.saer.client.label.TitleLabel;
import com.saer.client.tab.BaseTab;
import com.smartgwt.client.widgets.layout.HLayout;
import com.smartgwt.client.widgets.layout.VLayout;

public class PermissionsTab extends BaseTab {

	public PermissionsTab() {
		super();
		this.setTitle("User Permissions");

		TitleLabel userPermissionsTitle = new TitleLabel("User Permissions");
		PermissionsGrid userPermissionsGrid = new PermissionsGrid(true);
		VLayout userPermissionsLayout = new VLayout(5);
		userPermissionsLayout.addMember(userPermissionsTitle);
		userPermissionsLayout.addMember(userPermissionsGrid);
		
		TitleLabel allPermissionsTitle = new TitleLabel("All Permissions");
		PermissionsGrid allPermissionsGrid = new PermissionsGrid(false);
		VLayout allPermissionsLayout = new VLayout(5);
		allPermissionsLayout.addMember(allPermissionsTitle);
		allPermissionsLayout.addMember(allPermissionsGrid);
		
		TitleLabel userDetailsTitle = new TitleLabel("User Details");
		UserDetailsGrid userDetailsGrid = new UserDetailsGrid(userPermissionsGrid, allPermissionsGrid);
		VLayout userDetailsLayout = new VLayout(5);
		userDetailsLayout.addMember(userDetailsTitle);
		userDetailsLayout.addMember(userDetailsGrid);
		
		PermissionsSearchForm permissionsSearchForm = new PermissionsSearchForm(userDetailsGrid);
		
		HLayout topHLayout = new HLayout(20);
		topHLayout.setHeight(190);
		topHLayout.setLayoutMargin(10);
		topHLayout.addMember(permissionsSearchForm);
		topHLayout.addMember(userDetailsLayout);

		HLayout bottomHLayout = new HLayout(20);
		bottomHLayout.setLayoutMargin(10);
		bottomHLayout.addMember(allPermissionsLayout);
		bottomHLayout.addMember(userPermissionsLayout);

		VLayout vLayout = new VLayout();
		vLayout.addMember(topHLayout);
		vLayout.addMember(bottomHLayout);

		this.setPane(vLayout);
	}

}
